<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var zhishuo=function(a){
            
            if(a<=1||Math.floor(a)!=a){
                return a+'不是质数,也不是合数';
            }
            if(a==2){
                return '2是质数';
               
            }
            else{
                for(i=2;i<a;i++){
                    var result2=a%i;
                    if(result2==0){
                        return a+'是合数';
                    }
                }
                 return a+'是质数'; 
            }
        }
        alert(zhishuo(1));
         //方法二,思路:对a从1开始除,如果a的质数的个数大于2,则a是质数

        //字符串去除重复数
        var str='alfiedslfiueaifweiffjaew12547145eropqi'
        var obj={};
        var arr=[];
        for(j=0;j<str.length;j++){
            var ele=str.charAt(j);
            if(obj[ele]==undefined){
                arr.push(ele);
                obj[ele]=1;
                
            }
        }
        var str3=arr.join('');
        console.log(str3);

        //或者可以用一个数依次和数组中的数相比for(i=0){for{}}
        

        //数组去除重复数
        var arr2=['a','l','f','i','e','d','s','l','f','i','u','e','a','i','f','w','e','i','f','f','j','a','e','w','e','r','o','p','q','i']
        for(i=0;i<arr2.length;i++){
            for(j=i+1;j<=i;j++){
                if(arr2[i]==arr2[j]){
                    arr2.splice(j,1);
                    j--;
                }
            }
        }
        console.log(arr2);
        //对象的键名属于字符串,在使用obj[]方法调用时,应给键名加上引号,否则,结果未定义.
        var xiaoming={
            a:100,
            b:200,
            c:300,
            d:function(m){
                 var m=-m;
            }
        }
        xiaoming['f']=111;
        console.log(xiaoming);
    </script>
</body>
</html>